package top.buyibuyi.course.dao.admin;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import top.buyibuyi.course.pojo.Admin;
import top.buyibuyi.course.pojo.PageBean;

import java.util.List;

@Mapper
public interface SelectAdmin {

    @Select("<script>"
            + "select * from admin where 1=1 "
            +"<if test=\"name != null and name != ''\">"
            +" and name LIKE concat('%', #{name}, '%')"
            +"</if>"
            +"and id limit #{startPage},#{limit}"
            +"</script>")
    List<Admin> selectAdmin(@Param("startPage") int startPage, @Param("limit") int limit, @Param("name") String name);

    @Select("<script>"
            + "select count(*) as 'totalpage' from admin where 1=1 "
            +"<if test=\"name != null and name != ''\">"
            +" and name LIKE concat('%', #{name}, '%')"
            +"</if>"
            +"</script>")
    int selectCount(Admin name);

    @Select("select * from admin where id = #{id}")
    Admin selectAdminById(int id);


    @Select("select * from admin")
    List<Admin> selectAdminAll();
}
